import http from "@/api";
import {
  ApiAuthMenuTreeList,
  ApiMenuCreate,
  ApiMenuDelete,
  ApiMenuTreeList,
  ApiMenuTreePermission,
  ApiMenuTreeSelectList,
  ApiMenuUpdate
} from "@/constant/router";
import { SysMenuCreate } from "@/api/interface/SysMenu/SysMenuCreate";
import { SysMenuUpdate } from "@/api/interface/SysMenu/SysMenuUpdate";
import { SysMenuDelete } from "@/api/interface/SysMenu/SysMenuDelete";
import { dtoSysMenuCreate, dtoSysMenuDelete, dtoSysMenuUpdate } from "@/api/dbdto/dtoSysMenu";
import { dtoSysDictionaryUpdate } from "@/api/dbdto/dtoSysDictionary";
import { UnwrapRef } from "vue";

// 获取带权限控制的菜单列表
export const getAuthMenuListApi = () => {
  return http.post<Menu.MenuOptions[]>(ApiAuthMenuTreeList, {}, { noLoading: true });
};

// 获取普通的菜单列表
export const getAuthMenuPermissionApi = () => {
  return http.post<Menu.MenuOptions[]>(ApiMenuTreePermission, {}, { noLoading: true });
};

// 获取菜单列表-下拉框
export const getAuthMenuSelectListApi = () => {
  return http.post<Menu.MenuSelectOptions[]>(ApiMenuTreeSelectList, {}, { noLoading: true });
};

// 创建菜单
export const CreateSysMenu = (data: dtoSysMenuCreate) => {
  return http.post<SysMenuCreate>(ApiMenuCreate, data, { noLoading: false });
};

// 修改菜单
export const UpdateSysMenu = (data: UnwrapRef<dtoSysMenuUpdate>) => {
  return http.post<SysMenuCreate>(ApiMenuUpdate, data, { noLoading: false });
};

// 删除菜单
export const DeleteSysMenu = (data: dtoSysMenuDelete) => {
  return http.post<SysMenuCreate>(ApiMenuDelete, data, { noLoading: false });
};
